home *** CD-ROM | disk | FTP | other *** search
-
-
- 'Program name: vbinput.bas
- ' Visual Basic 1.0 input routines
- ' Version: 1.01
- '
- ' (c) 1991 by Keith Milligan
- ' 100 Lee Road 605
- ' Smiths, AL 36877
- ' 205-291-9712 Home
- ' 205-298-1974 Work
- ' Compuserve ID = 70645,520
-
- 'Use these routines if they will help you. You may use,
- 'modify, copy, or distribute them with a clear concience.
-
- 'Visual Basic 1.0 input routines
-
- 'Version control information:
- ' 1.00 - 07/01/91
- ' Initial release
- ' 1.01 - 10/03/91
- ' Allow selected text to be replaced when the maximum
- ' length has been reached.
-
- 'These routines use two events for each text control.
- 'There is a Sub for the KeyPress event and a corresponding
- 'Function for the LostFocus Event. The KeyPress (KP) routine
- 'restricts certain keystrokes and the LostFocus (LF) routine
- 'validates the data entered in the text control and assigns
- 'the entered data to a variable.
-
-
- 'Date
- ' Sub DateKP(ThisControl, KeyAscii)
- ' Function DateLF$(ThisControl, EarliestDate$)
- ' Format of EarliestDate$ is "yymmdd".
- ' Accepts date entered in one of the following formats:
- ' 60491, 060491, 06/04/91, or 6/4/91
- ' Returns date in the format 910604.
-
- 'MultPrice
- ' Sub MultPriceKP(ThisControl, KeyAscii)
- ' Function MultPriceLF$(ThisControl)
- ' Used to accept retail prices. For example 3 for $1.00.
- ' Accepts and returns in the following formats:
- ' Input Returns
- ' 149 01/01.49
- ' 1.49 01/01.49
- ' 3/49 03/00.49
- ' 3/.49 03/00.49
-
- 'Point2
- ' Sub Point2KP(ThisControl, Length%, KeyAscii)
- ' Function Point2LF(ThisControl, Min#, Max#)
- ' Accepts number with two digits to the right of the decimal point.
- ' Maximum length = Length%
- ' Minimum value = Min#
- ' Maximum value = Max#
- ' Example 123.49
-
- 'Point4
- ' Sub Point4KP(ThisControl, Length%, KeyAscii)
- ' Function Point4LF(ThisControl, Min#, Max#)
- ' Accepts number with four digits to the right of the decimal point.
- ' Maximum length = Length%
- ' Minimum value = Min#
- ' Maximum value = Max#
- ' Example 123.4978
-
- 'Str
- ' Sub StrKP(ThisControl, Length%, KeyAscii)
- ' No LF function for this routine. Just move text to string in
- ' LostFocus Event.
- ' Accepts string of length less than or equal to Length%.
-
- 'UCStr
- ' Sub UCStrKP(ThisControl, Length%, KeyAscii)
- ' No LF function for this routine just move text to string in
- ' LostFocus Event.
- ' Accepts string of length less than or equal to Length%.
- ' Converts characters to upper case as typed.
-
- 'Long
- ' Sub LongKP(ThisControl, Length%, KeyAscii)
- ' Function LongLF&(ThisControl, Min&, Max&)
- ' Accepts long integer amount.
-
- 'Int
- ' Sub IntKP(ThisControl, Length%, KeyAscii)
- ' Function IntLF%(ThisControl, Min%, Max%)
- ' Same as Long but accepts normal integer amounts
-
- 'Curr2
- ' Sub Curr2KP(ThisControl, Length%, KeyAscii)
- ' Function Curr2LF@(ThisControl, Min@, Max@)
- ' Same as Point2 but for currency data type.
-
- 'Curr4
- ' Sub Curr4KP(ThisControl, Length%, KeyAscii)
- ' Function Curr4LF(ThisControl, Min@, Max@)
- ' Same as Point4 but for currency data type.
-
- 'DateSer
- ' Sub DateSerKP(Thiscontrol, KeyAscii)
- ' Function DateSerLF@(ThisControl, EarliestDate$)
- ' Same as Date but returns date serial number instead of yymmdd.
-
- 'ProgBar
- ' Sub ProgBar(ThisControl, PDone%)
- ' This Control = a picture control with
- ' ScaleHeight = 1 and ScaleWidth = 100
- ' PDone% = Percent complete integer
-
- 'SelectText
- ' Sub SelectText(ThisControl)
- ' Selects all the text in this control
-
- '
- Sub Curr2KP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- StringLength% = Len(ThisControl.Text)
- DecimalPosition% = InStr(ThisControl.Text, ".")
- If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
- If ThisControl.SelStart < DecimalPosition% Then
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "."
- If ThisControl.SelLength <> Len(ThisControl.Text) Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- ElseIf KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "."
- If InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End If
- End Sub
-
- Function Curr2LF@ (ThisControl As Control, Min@, Max@)
- Test@ = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test@ < Min@ Or Test@ > Max@ Then
- Beep
- Msg$ = "Number must be between " + Str$(Min@) + " and " + Str$(Max@)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- Curr2LF@ = Test@
- End If
- End If
-
- End Function
-
- Sub Curr4KP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- StringLength% = Len(ThisControl.Text)
- DecimalPosition% = InStr(ThisControl.Text, ".")
- If StringLength% - DecimalPosition% = 4 And DecimalPosition% <> 0 Then
- If ThisControl.SelStart < DecimalPosition% Then
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "."
- If ThisControl.SelLength <> Len(ThisControl.Text) Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- ElseIf KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "."
- If InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End If
- End Sub
-
- Function Curr4LF@ (ThisControl As Control, Min@, Max@)
- Test@ = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test@ < Min@ Or Test@ > Max@ Then
- Beep
- Msg$ = "Number must be between " + Str$(Min@) + " and " + Str$(Max@)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- Curr4LF@ = Test@
- End If
- End If
-
- End Function
-
- Sub DateKP (ThisControl As Control, KeyAscii As Integer)
- C$ = Chr$(KeyAscii)
- Test$ = ThisControl.Text
- If Len(Test$) = 6 And InStr(Test$, "/") = 0 Then
- If ThisControl.SelLength <> 6 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
- If ThisControl.SelLength <> 8 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8), "/"
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End Sub
-
- Function DateLF$ (ThisControl As Control, EarliestDate$)
- If ThisControl.Text <> "" Then
- BadDate$ = "N"
- InDate$ = ThisControl.Text
- If Len(InDate$) = 5 Then
- InDate$ = "0" + InDate$
- ElseIf Len(InDate$) = 6 Then
- If InStr(InDate$, "/") <> 0 Then
- InDate$ = "0" + Left$(InDate$, 1) + "0" + Mid$(InDate$, 3, 1) + Mid$(InDate$, 5, 2)
- End If
- ElseIf Len(InDate$) = 7 Then
- If Mid$(InDate$, 2, 1) = "/" Then
- InDate$ = "0" + Left$(InDate$, 1) + Mid$(InDate$, 3, 2) + Mid$(InDate$, 6, 2)
- Else
- InDate$ = Left$(InDate$, 2) + "0" + Mid$(InDate$, 4, 1) + Mid$(InDate$, 6, 2)
- End If
- ElseIf Len(InDate$) = 8 Then
- InDate$ = Left$(InDate$, 2) + Mid$(InDate$, 4, 2) + Mid$(InDate$, 7, 2)
- Else
- BadDate$ = "Y"
- End If
- If InStr(InDate$, "/") <> 0 And BadDate$ = "N" Then
- Temp3$ = Right$(InDate$, 2)
- If InStr(Temp3$, "/") <> 0 Then
- BadDate$ = "Y"
- End If
- End If
- If InStr(InDate$, "/") = 0 And BadDate$ = "N" Then
- Months% = Val(Left$(InDate$, 2))
- Days% = Val(Mid$(InDate$, 3, 2))
- Select Case Months%
- Case 1, 3, 5, 7, 8, 10, 12
- If Days% < 1 Or Days% > 31 Then
- BadDate$ = "Y"
- End If
- Case 4, 6, 9, 11
- If Days% < 1 Or Days% > 30 Then
- BadDate$ = "Y"
- End If
- Case 2
- If Days% < 1 Or Days% > 29 Then
- BadDate$ = "Y"
- End If
- Case Else
- BadDate$ = "Y"
- End Select
- End If
- InDate$ = Mid$(InDate$, 5, 2) + Left$(InDate$, 4)
- If InDate$ < EarliestDate$ And Left$(InDate$, 2) > "30" Then
- BadDate$ = "Y"
- End If
- If BadDate$ = "Y" Then
- Beep
- Msg$ = "Not a valid date."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- If Left$(InDate$, 2) > "20" Then
- InDate$ = "19" + InDate$
- Else
- InDate$ = "20" + InDate$
- End If
- Temp# = DateSerial(Val(Left$(InDate$, 4)), Val(Mid$(InDate$, 5, 2)), Val(Mid$(InDate$, 7, 2)))
- ThisControl.Text = Format$(Temp#, "mm/dd/yy")
- Temp2$ = ThisControl.Text
- DateLF$ = Right$(Temp2$, 2) + Left$(Temp2$, 2) + Mid$(Temp2$, 4, 2)
- End If
- End If
- End Function
-
- Sub DateSerKP (ThisControl As Control, KeyAscii As Integer)
- C$ = Chr$(KeyAscii)
- Test$ = ThisControl.Text
- If Len(Test$) = 6 And InStr(Test$, "/") = 0 Then
- If ThisControl.SelLength <> 6 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
- If ThisControl.SelLength <> 8 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8), "/"
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End Sub
-
- Function DateSerLF# (ThisControl As Control, EarliestDate$)
- If ThisControl.Text <> "" Then
- BadDate$ = "N"
- InDate$ = ThisControl.Text
- If Len(InDate$) = 5 Then
- InDate$ = "0" + InDate$
- ElseIf Len(InDate$) = 6 Then
- If InStr(InDate$, "/") <> 0 Then
- InDate$ = "0" + Left$(InDate$, 1) + "0" + Mid$(InDate$, 3, 1) + Mid$(InDate$, 5, 2)
- End If
- ElseIf Len(InDate$) = 7 Then
- If Mid$(InDate$, 2, 1) = "/" Then
- InDate$ = "0" + Left$(InDate$, 1) + Mid$(InDate$, 3, 2) + Mid$(InDate$, 6, 2)
- Else
- InDate$ = Left$(InDate$, 2) + "0" + Mid$(InDate$, 4, 1) + Mid$(InDate$, 6, 2)
- End If
- ElseIf Len(InDate$) = 8 Then
- InDate$ = Left$(InDate$, 2) + Mid$(InDate$, 4, 2) + Mid$(InDate$, 7, 2)
- Else
- BadDate$ = "Y"
- End If
- If InStr(InDate$, "/") <> 0 And BadDate$ = "N" Then
- Temp3$ = Right$(InDate$, 2)
- If InStr(Temp3$, "/") <> 0 Then
- BadDate$ = "Y"
- End If
- End If
- If InStr(InDate$, "/") = 0 And BadDate$ = "N" Then
- Months% = Val(Left$(InDate$, 2))
- Days% = Val(Mid$(InDate$, 3, 2))
- Select Case Months%
- Case 1, 3, 5, 7, 8, 10, 12
- If Days% < 1 Or Days% > 31 Then
- BadDate$ = "Y"
- End If
- Case 4, 6, 9, 11
- If Days% < 1 Or Days% > 30 Then
- BadDate$ = "Y"
- End If
- Case 2
- If Days% < 1 Or Days% > 29 Then
- BadDate$ = "Y"
- End If
- Case Else
- BadDate$ = "Y"
- End Select
- End If
- InDate$ = Mid$(InDate$, 5, 2) + Left$(InDate$, 4)
- If InDate$ < EarliestDate$ And Left$(InDate$, 2) > "30" Then
- BadDate$ = "Y"
- End If
- If BadDate$ = "Y" Then
- Beep
- Msg$ = "Not a valid date."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- If Left$(InDate$, 2) > "20" Then
- InDate$ = "19" + InDate$
- Else
- InDate$ = "20" + InDate$
- End If
- Temp# = DateSerial(Val(Left$(InDate$, 4)), Val(Mid$(InDate$, 5, 2)), Val(Mid$(InDate$, 7, 2)))
- DateSerLF# = Temp#
- ThisControl.Text = Format$(Temp#, "mm/dd/yy")
- End If
- End If
-
- End Function
-
- Function FileExists% (FileName$)
- On Error GoTo FEErrorCode
- FileNum = FreeFile
- Open FileName$ For Random As FileNum Len = 1
- If LOF(FileNum) = 0 Then
- Close FileNum
- Kill FileName$
- FileExists% = False
- Else
- Close FileNum
- FileExists% = True
- End If
- Exit Function
- FEErrorCode:
- FileExists% = False
- Resume FEErrorExit
- FEErrorExit:
-
- End Function
-
- Sub IntKP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End Sub
-
- Function IntLF% (ThisControl As Control, Min%, Max%)
- On Local Error GoTo ErrorHandler
- Test% = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test% < Min% Or Test% > Max% Then
- Beep
- Msg$ = "Number must be between " + Str$(Min%) + " and " + Str$(Max%)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- IntLF% = Test%
- End If
- End If
- Exit Function
- ErrorHandler:
- Beep
- Msg$ = "The number must be a valid integer amount."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Resume EndErrorHandler
- EndErrorHandler:
- End Function
-
- Sub LongKP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End Sub
-
- Function LongLF& (ThisControl As Control, Min&, Max&)
- On Local Error GoTo ErrorHandler2
- Test& = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test& < Min& Or Test& > Max& Then
- Beep
- Msg$ = "Number must be between " + Str$(Min&) + " and " + Str$(Max&)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- LongLF& = Test&
- End If
- End If
- Exit Function
- ErrorHandler2:
- Beep
- Msg$ = "The number must be a valid long integer amount."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Resume EndErrorHandler2
- EndErrorHandler2:
- End Function
-
- Sub MultPriceKP (ThisControl As Control, KeyAscii As Integer)
- C$ = Chr$(KeyAscii)
- Test$ = ThisControl.Text
- If Len(Test$) = 5 And InStr(Test$, "/") = 0 Then
- If ThisControl.SelLength <> 5 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- ElseIf Len(Test$) = 8 And InStr(Test$, "/") <> 0 Then
- If ThisControl.SelLength <> 8 Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- StringLength% = Len(ThisControl.Text)
- DecimalPosition% = InStr(ThisControl.Text, ".")
- If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
- If ThisControl.SelLength <> StringLength% Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "."
- If InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "/"
- If InStr(ThisControl.Text, "/") <> 0 Or InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End If
- End Sub
-
- Function MultPriceLF$ (ThisControl As Control)
- If Len(ThisControl.Text) <> 0 Then
- BadQuantity$ = "N"
- BadAmount$ = "N"
- Temp$ = ThisControl.Text
- If InStr(Temp$, "/") = 0 Then
- Qty$ = "01"
- Amt$ = Temp$
- Else
- Qty$ = Left$(Temp$, InStr(Temp$, "/") - 1)
- Amt$ = Right$(Temp$, Len(Temp$) - InStr(Temp$, "/"))
- End If
- QtyLength% = Len(Qty$)
- Select Case QtyLength%
- Case 1
- Qty$ = "0" + Qty$
- Case 2
- Case Else
- BadQuantity$ = "Y"
- End Select
- If InStr(Amt$, ".") = 0 Then
- Amt$ = Left$(Amt$, Len(Amt$) - 2) + "." + Right$(Amt$, 2)
- End If
- If InStr(Amt$, ".") = Len(Amt$) - 1 Then
- Amt$ = Amt$ + "0"
- End If
- If InStr(Amt$, ".") = Len(Amt$) Then
- Amt$ = Amt$ + "00"
- End If
- Amt$ = String$(5 - Len(Amt$), "0") + Amt$
- If Val(Amt$) > 99.99 Or Val(Amt$) < .01 Then
- BadAmount$ = "Y"
- End If
- If Val(Qty$) > 99 Or Val(Qty$) < 1 Then
- BadQuantity$ = "Y"
- End If
- If BadAmount$ = "Y" Then
- Beep
- Msg$ = "Price is not valid."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- ElseIf BadQuantity$ = "Y" Then
- Beep
- Msg$ = "Quantity is not valid."
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- ThisControl.Text = Qty$ + "/" + Amt$
- MultPriceLF$ = ThisControl.Text
- End If
- End If
- End Function
-
- Sub Point2KP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- StringLength% = Len(ThisControl.Text)
- DecimalPosition% = InStr(ThisControl.Text, ".")
- If StringLength% - DecimalPosition% = 2 And DecimalPosition% <> 0 Then
- If ThisControl.SelStart < DecimalPosition% Then
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "."
- If ThisControl.SelLength <> Len(ThisControl.Text) Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- ElseIf KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "."
- If InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End If
- End Sub
-
- Function Point2LF# (ThisControl As Control, Min#, Max#)
- Test# = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test# < Min# Or Test# > Max# Then
- Beep
- Msg$ = "Number must be between " + Str$(Min#) + " and " + Str$(Max#)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- Point2LF# = Test#
- End If
- End If
- End Function
-
- Sub Point4KP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- C$ = Chr$(KeyAscii)
- StringLength% = Len(ThisControl.Text)
- DecimalPosition% = InStr(ThisControl.Text, ".")
- If StringLength% - DecimalPosition% = 4 And DecimalPosition% <> 0 Then
- If ThisControl.SelStart < DecimalPosition% Then
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "."
- If ThisControl.SelLength <> Len(ThisControl.Text) Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- ElseIf KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- Else
- Select Case C$
- Case "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", Chr$(8)
- Case "."
- If InStr(ThisControl.Text, ".") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case "-"
- If ThisControl.SelStart <> 0 Or InStr(ThisControl.Text, "-") <> 0 Then
- KeyAscii = 0
- Beep
- End If
- Case Else
- KeyAscii = 0
- Beep
- End Select
- End If
- End If
- End Sub
-
- Function Point4LF# (ThisControl As Control, Min#, Max#)
- Test# = Val(ThisControl.Text)
- If ThisControl.Text <> "" Then
- If Test# < Min# Or Test# > Max# Then
- Beep
- Msg$ = "Number must be between " + Str$(Min#) + " and " + Str$(Max#)
- MsgBox Msg$, 0, "Warning"
- ThisControl.SetFocus
- Else
- Point4LF# = Test#
- End If
- End If
- End Function
-
-
- Sub ProgBar (ThisControl As Control, PDone%)
- TotHeight% = ThisControl.ScaleHeight
- TotWidth% = ThisControl.ScaleWidth
- DoneWidth% = TotWidth% * (PDone% / 100)
- ThisControl.Line (DoneWidth%, 0)-(TotWidth%, TotHeight%), RGB(255, 255, 255), BF
- ThisControl.Line (0, 0)-(DoneWidth%, TotHeight%), RGB(0, 0, 128), BF
- Pct$ = Format$(PDone, " ##\% ")
- If PDone < 50 Then
- ThisControl.CurrentX = DoneWidth%
- ThisControl.ForeColor = RGB(0, 0, 0)
- Else
- ThisControl.CurrentX = DoneWidth% - ThisControl.TextWidth(Pct$)
- ThisControl.ForeColor = RGB(255, 255, 255)
- End If
- ThisControl.CurrentY = (TotHeight% - ThisControl.TextHeight(Pct$)) / 2
- ThisControl.Print Pct$
- End Sub
-
- Sub SelectText (ThisControl As Control)
- ThisControl.SelStart = 0
- ThisControl.SelLength = Len(ThisControl.Text)
- End Sub
-
- Sub StrKP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length% Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- End If
- End Sub
-
- Sub UCStrKP (ThisControl As Control, Length%, KeyAscii As Integer)
- If Len(ThisControl.Text) = Length% Then
- If ThisControl.SelLength <> Length% Then
- If KeyAscii <> 8 Then
- KeyAscii = 0
- Beep
- End If
- End If
- Else
- KeyAscii = Asc(UCase$(Chr$(KeyAscii)))
- End If
- End Sub
-
-